package com.bosssoft.trainee.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bosssoft.trainee.entity.dto.MenuDTO;
import com.bosssoft.trainee.entity.po.Menu;
import com.bosssoft.trainee.entity.vo.MenuVO;
import com.bosssoft.trainee.mapper.MenuMapper;
import com.bosssoft.trainee.service.MenuService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuqiang
 * @date 2022/7/6 23:09
 */
@Service
public class MenuServiceImp extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    public List<MenuDTO> getMenuByRole(Integer roleId){
        QueryWrapper<Menu> menuQueryWrapper = new QueryWrapper<>();
        menuQueryWrapper.eq("role_id",roleId);
        List<Menu> list = this.list(menuQueryWrapper);
        List<MenuDTO> menuDTOList = new ArrayList<>();
        for(Menu menu:list){
            MenuDTO menuDTO = new MenuDTO();
            BeanUtils.copyProperties(menu,menuDTO);
            menuDTOList.add(menuDTO);
        }
        return menuDTOList;
    }

    public List<MenuDTO> getMenuByPath(List<String> list){

        return null;
    }
}
